package server.command.list;

import java.util.Collection;

import communication.exception.VerifyParameterException;

import server.command.AnalysisCommand;
import server.command.Command;
import server.core.base.Flight;
import server.core.dao.DaoFactory;
import server.core.manager.Guest;
import server.core.manager.Manager;

public class ShowFlight implements Command {
	private AnalysisCommand parsing;
	@Override
	public Collection<Object> execute() {
		Collection<Object> result = parsing.getArgsMap().values();
		return result;
	}

	@Override
	public void verifyParam(AnalysisCommand parsing) throws VerifyParameterException,NumberFormatException {
		this.parsing=parsing;
		for(String key:AnalysisCommand.paramId){
			if(parsing.getParamMap().containsKey(key)){
				Flight flight=(Flight) DaoFactory.getDao(parsing.getTypeOfDao()).getObject(Flight.class, Long.parseLong(parsing.getParamMap().get(key)));
					if(flight==null)
						throw new VerifyParameterException("There isn`t flight with this id");
					else
						parsing.getArgsMap().put(key, flight);
			}
			else
				throw new VerifyParameterException(
						"Parameter Error. Type \"help <command>\" to print list of available parameters");
		}
	}

	@Override
	public String help() {
		return " id=<Flight>";

	}

	@Override
	public Class<? extends Manager> getManager() {
		return Guest.class;
	}

	@Override
	public void exit() {
		// TODO Auto-generated method stub
		
	}

}
